<?php   $role = $this->session->read('Auth.User.role');


if($role=='Admin'){ ?>
<div class="products form">
<?php echo $this->Form->create('Product', array('enctype' => 'multipart/form-data')); ?>
   
   
		<?php echo __('<h2>Add Ads</h2>'); ?>
     <div class="col-left">
	<?php 
      
         //  echo $Product['Category']['name']; 
                
		echo $this->Form->input('parent_id', array('name'=>'data[Product][category_id]', 'class'=>'form-control'));
		echo $this->Form->input('user_id', array('class'=>'form-control'));
		 echo $this->Form->input('title', array('class' => 'form-control'));
                                ?>
                                <div class="input text required">
                                    <label for="ProductStatus">Status</label>
                                    <select required="required" id="ProductStatus" name="data[Product][status]" class="form-control">
                                    <option value="new">New</option>
                                    <option value="used">Used</option>
                                    <option value="other">Other</option>
                                    </select>
                                </div>
                                <div class="input text required">
                                    <label for="ProductType">Type</label>
                                    <select required="required" id="ProductType" name="data[Product][type]" class="form-control">
                                    <option value="sale">Sale</option>
                                    <option value="buy">Buy</option>
                                    <option value="promotion">Promotion</option>
                                    <option value="other">Other</option>
                                    </select>
                                </div>
                                    <?php $userphone = $this->session->read('Auth.User.phone');
                                    $useremail = $this->session->read('Auth.User.email');
                                    $username = $this->session->read('Auth.User.first_name').' '.$this->session->read('Auth.User.last_name');

                                                        echo $this->Form->input('price', array('class' => 'form-control'));
                                                        echo $this->Form->input('description', array('class' => 'form-control'));
                                                             
                                                        ?></div><div class="col-right"><?php
                                                        echo $this->Form->input('location_id', array('class' => 'form-control'));
                                                        echo $this->Form->input('address', array('class' => 'form-control'));
                                                         echo $this->Form->input('name', array('class'=>'form-control','value'=>$username));
                                                        echo $this->Form->input('phone', array('class' => 'form-control','maxlength'=>'50','value'=>$userphone));
                                                        echo $this->Form->input('email', array('class' => 'form-control','value'=>$useremail));

                                    if (!empty($this->request->data['Product']['picture1'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture1'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture1', array('type' => 'file'));

                                    if (!empty($this->request->data['Product']['picture2'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture2'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture2', array('type' => 'file'));

                                     if (!empty($this->request->data['Product']['picture3'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture3'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture3', array('type' => 'file'));

                                      if (!empty($this->request->data['Product']['picture4'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture4'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture4', array('type' => 'file'));
                                   
	?>
	
<?php echo $this->Form->end(__('Save')); ?>
                                                            </div>
</div>


<?php } elseif($role=='Register') { ?>

<div class="ads-form">
    <div class="list-group">
        <div class="list-group-item">
                    <?php echo $this->Form->create('Product', array('enctype' => 'multipart/form-data')); ?>
                        <fieldset>
                            <legend><?php echo __('My Ads'); ?></legend>
                            <div id="form-fill">
                                <?php 
                              $user_id = $this->session->read('Auth.User.id');
                                 //  echo $Product['Category']['name']; 
                                // print_r($catlist);
            ?>
                                <label>Select Category</label>
                            <select name="data[Product][category_id]" class="form-control">
                               <?php foreach($catlist as $catlists){
                                   ?><option value="<?php echo $catlists['Category']['id']; ?>"><?php echo $catlists['Category']['name']; ?></option><?php
                               } ?> 
                            </select>
                                <?php
                             //   echo $this->Form->input('parent_id', array('name'=>'data[Product][category_id]', 'class' => 'form-control'));
                                echo $this->Form->input('user_id', array('type'=>'hidden','value'=>$user_id, 'class' => 'form-control'));
                                echo $this->Form->input('title', array('class' => 'form-control'));
                                ?>
                                <div class="input text required">
                                    <label for="ProductStatus">Status</label>
                                    <select required="required" id="ProductStatus" name="data[Product][status]" class="form-control">
                                    <option value="new">New</option>
                                    <option value="used">Used</option>
                                    <option value="other">Other</option>
                                    </select>
                                </div>
                                <div class="input text required">
                                    <label for="ProductType">Type</label>
                                    <select required="required" id="ProductType" name="data[Product][type]" class="form-control">
                                    <option value="sale">Sale</option>
                                    <option value="buy">Buy</option>
                                    <option value="promotion">Promotion</option>
                                    <option value="other">Other</option>
                                    </select>
                                </div>
                                    <?php $userphone = $this->session->read('Auth.User.phone');
                                    $useremail = $this->session->read('Auth.User.email');
                                    $username = $this->session->read('Auth.User.first_name').' '.$this->session->read('Auth.User.last_name');

                                                        echo $this->Form->input('price', array('class' => 'form-control'));
                                                        echo $this->Form->input('description', array('class' => 'form-control'));
                                                        echo $this->Form->input('location_id', array('class' => 'form-control'));
                                                        echo $this->Form->input('address', array('class' => 'form-control'));
                                                         echo $this->Form->input('name', array('class'=>'form-control','value'=>$username));
                                                        echo $this->Form->input('phone', array('class' => 'form-control','value'=>$userphone));
                                                        echo $this->Form->input('email', array('class' => 'form-control','value'=>$useremail));

                                    if (!empty($this->request->data['Product']['picture1'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture1'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture1', array('type' => 'file'));

                                    if (!empty($this->request->data['Product']['picture2'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture2'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture2', array('type' => 'file'));

                                     if (!empty($this->request->data['Product']['picture3'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture3'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture3', array('type' => 'file'));

                                      if (!empty($this->request->data['Product']['picture4'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture4'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture4', array('type' => 'file'));
                                   

                              
                        ?>
                               <?php echo $this->Form->end(__('Submit')); ?>
                            </div>
                        </fieldset>            
    </div>
    </div>
</div>

<?php } else {
             ?>
<div class="ads-form">
    <div class="list-group">
        <div class="list-group-item">
                    <?php echo $this->Form->create('Product', array('enctype' => 'multipart/form-data')); ?>
                        <fieldset>
                            <legend><?php echo __('My Ads'); ?></legend>
                            <div id="form-fill">
                                <?php 
                              $user_id = $this->session->read('Auth.User.id');
                                 //  echo $Product['Category']['name']; 
                                // print_r($catlist);
            ?>
                                <label>Select Category</label>
                            <select name="data[Product][category_id]" class="form-control">
                               <?php foreach($catlist as $catlists){
                                   ?><option value="<?php echo $catlists['Category']['id']; ?>"><?php echo $catlists['Category']['name']; ?></option><?php
                               } ?> 
                            </select>
                                <?php $userid=$this->session->read('userid');
                                           $faceuser=$this->session->read('username');
                             //   echo $this->Form->input('parent_id', array('name'=>'data[Product][category_id]', 'class' => 'form-control'));
                                echo $this->Form->input('user_id', array('type'=>'hidden','value'=>$userid, 'class' => 'form-control'));
                                echo $this->Form->input('title', array('class' => 'form-control'));
                                ?>
                                <div class="input text required">
                                    <label for="ProductStatus">Status</label>
                                    <select required="required" id="ProductStatus" name="data[Product][status]" class="form-control">
                                    <option value="new">New</option>
                                    <option value="used">Used</option>
                                    <option value="other">Other</option>
                                    </select>
                                </div>
                                <div class="input text required">
                                    <label for="ProductType">Type</label>
                                    <select required="required" id="ProductType" name="data[Product][type]" class="form-control">
                                    <option value="sale">Sale</option>
                                    <option value="buy">Buy</option>
                                    <option value="promotion">Promotion</option>
                                    <option value="other">Other</option>
                                    </select>
                                </div>
                                    <?php 

                                                        echo $this->Form->input('price', array('class' => 'form-control'));
                                                        echo $this->Form->input('description', array('class' => 'form-control'));
                                                        echo $this->Form->input('location_id', array('class' => 'form-control'));
                                                        echo $this->Form->input('address', array('class' => 'form-control'));
                                                        echo $this->Form->input('name', array('class' => 'form-control','value'=>$faceuser));
                                                        echo $this->Form->input('phone', array('class' => 'form-control'));
                                                        echo $this->Form->input('email', array('class' => 'form-control'));

                                    if (!empty($this->request->data['Product']['picture1'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture1'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture1', array('type' => 'file'));

                                    if (!empty($this->request->data['Product']['picture2'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture2'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture2', array('type' => 'file'));

                                     if (!empty($this->request->data['Product']['picture3'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture3'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture3', array('type' => 'file'));

                                      if (!empty($this->request->data['Product']['picture4'])) {
                                        echo $this->Html->image('uploads/' . $this->request->data['Product']['picture4'], array('width' => '140px', 'style' => 'margin-left13px'));
                                    }
                                    echo $this->Form->input('picture4', array('type' => 'file'));
                                   

                              
                        ?>
                               <?php echo $this->Form->end(__('Submit')); ?>
                            </div>
                        </fieldset>            
    </div>
    </div>
</div>           
<?php }?>
